package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cleaningcloud.cld.domain.dto.CldPayConfirmDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldInputDeduction;
import com.cleaningcloud.cld.service.ICldInputDeductionService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 进项抵扣Controller
 * 
 * @author cleaningcloud
 * @date 2025-04-27
 */
@RestController
@RequestMapping("/inputDeduction")
public class CldInputDeductionController extends BaseController
{
    @Autowired
    private ICldInputDeductionService cldInputDeductionService;

    /**
     * 查询进项抵扣列表
     */
    @RequiresPermissions("cld:inputDeduction:list")
    @GetMapping("/list")
    public TableDataInfo list(CldInputDeduction cldInputDeduction)
    {
        startPage();
        List<CldInputDeduction> list = cldInputDeductionService.selectCldInputDeductionList(cldInputDeduction);
        return getDataTable(list);
    }

    /**
     * 导出进项抵扣列表
     */
    @RequiresPermissions("cld:inputDeduction:export")
    @Log(title = "进项抵扣", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldInputDeduction cldInputDeduction)
    {
        List<CldInputDeduction> list = cldInputDeductionService.selectCldInputDeductionList(cldInputDeduction);
        ExcelUtil<CldInputDeduction> util = new ExcelUtil<CldInputDeduction>(CldInputDeduction.class);
        util.exportExcel(response, list, "进项抵扣数据");
    }

    /**
     * 获取进项抵扣详细信息
     */
    @RequiresPermissions("cld:inputDeduction:query")
    @GetMapping(value = "/{inputDeductionId}")
    public AjaxResult getInfo(@PathVariable("inputDeductionId") Long inputDeductionId)
    {
        return success(cldInputDeductionService.selectCldInputDeductionByInputDeductionId(inputDeductionId));
    }

    /**
     * 新增进项抵扣
     */
    @RequiresPermissions("cld:inputDeduction:add")
    @Log(title = "进项抵扣", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldInputDeduction cldInputDeduction)
    {
        return toAjax(cldInputDeductionService.insertCldInputDeduction(cldInputDeduction));
    }

    /**
     * 修改进项抵扣
     */
    @RequiresPermissions("cld:inputDeduction:edit")
    @Log(title = "进项抵扣", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldInputDeduction cldInputDeduction)
    {
        return toAjax(cldInputDeductionService.updateCldInputDeduction(cldInputDeduction));
    }

    /**
     * 删除进项抵扣
     */
    @RequiresPermissions("cld:inputDeduction:remove")
    @Log(title = "进项抵扣", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inputDeductionIds}")
    public AjaxResult remove(@PathVariable Long[] inputDeductionIds)
    {
        return toAjax(cldInputDeductionService.deleteCldInputDeductionByInputDeductionIds(inputDeductionIds));
    }

    /**
     * 批量修改抵扣
     */
    @RequiresPermissions("cld:inputDeduction:edit")
    @Log(title = "批量修改抵扣", businessType = BusinessType.UPDATE)
    @PutMapping("/batchDeduction")
    public AjaxResult batchDeduction(@RequestBody CldInputDeduction cldInputDeduction) {
        return toAjax(cldInputDeductionService.batchDeduction(cldInputDeduction));
    }
}
